package com.ruoyi.car.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.car.domain.CarParkRecord;
import com.ruoyi.car.service.ICarParkRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车情况Controller
 * 
 * @author ruoyi
 * @date 2022-12-03
 */
@RestController
@RequestMapping("/car/parkRecord")
public class CarParkRecordController extends BaseController
{
    @Autowired
    private ICarParkRecordService carParkRecordService;

    /**
     * 查询停车情况列表
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarParkRecord carParkRecord)
    {
        startPage();
        List<CarParkRecord> list = carParkRecordService.selectCarParkRecordList(carParkRecord);
        return getDataTable(list);
    }

    /**
     * 导出停车情况列表
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:export')")
    @Log(title = "停车情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarParkRecord carParkRecord)
    {
        List<CarParkRecord> list = carParkRecordService.selectCarParkRecordList(carParkRecord);
        ExcelUtil<CarParkRecord> util = new ExcelUtil<CarParkRecord>(CarParkRecord.class);
        util.exportExcel(response, list, "停车情况数据");
    }

    /**
     * 获取停车情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:query')")
    @GetMapping(value = "/{parkRecordId}")
    public AjaxResult getInfo(@PathVariable("parkRecordId") Long parkRecordId)
    {
        return success(carParkRecordService.selectCarParkRecordByParkRecordId(parkRecordId));
    }

    /**
     * 新增停车情况
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:add')")
    @Log(title = "停车情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarParkRecord carParkRecord)
    {
        return toAjax(carParkRecordService.insertCarParkRecord(carParkRecord));
    }

    /**
     * 修改停车情况
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:edit')")
    @Log(title = "停车情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarParkRecord carParkRecord)
    {
        return toAjax(carParkRecordService.updateCarParkRecord(carParkRecord));
    }

    /**
     * 删除停车情况
     */
    @PreAuthorize("@ss.hasPermi('car:parkRecord:remove')")
    @Log(title = "停车情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parkRecordIds}")
    public AjaxResult remove(@PathVariable Long[] parkRecordIds)
    {
        return toAjax(carParkRecordService.deleteCarParkRecordByParkRecordIds(parkRecordIds));
    }
}
